package com.csc.contact.checkbill.utiltools.ftp;


import org.apache.log4j.Logger;

import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
 *
 * @author zhanglei
 * @date 2019/6/17 20:37
 * call_data_service
 */
public class FtpConfig {
    //定义配置文件对象
    private static Properties ftpConfig;
    public final static Map<String,String> config = new HashMap<String,String>();
    private final static Logger logger = Logger.getLogger(FtpConfig.class);

    static {
        try {
            //实例化配置文件文件对象
            ftpConfig = new Properties();
            //拿到配置文件的输入流
            //得到类加载器对象
            ClassLoader cl = FtpConfig.class.getClassLoader();
            //通过类加载器对象得到指定资源的字节流
            InputStream in = cl.getResourceAsStream("config/data.properties");
            //将配置文件的输入流加载进ftpConfig对象
            ftpConfig.load(in);
            config.put("path_start", ftpConfig.getProperty("path_start"));
            config.put("ftp.ip", ftpConfig.getProperty("ftp.ip"));
            config.put("ftp.userName", ftpConfig.getProperty("ftp.userName"));
            config.put("ftp.passwd", ftpConfig.getProperty("ftp.passwd"));
            config.put("ftp.port", ftpConfig.getProperty("ftp.port"));
            config.put("hk.ip", ftpConfig.getProperty("hk.ip"));
            config.put("hk.userName", ftpConfig.getProperty("hk.userName"));
            config.put("hk.passwd", ftpConfig.getProperty("hk.passwd"));
            config.put("hk.port", ftpConfig.getProperty("hk.port"));
            config.put("ftp.encode", ftpConfig.getProperty("ftp.encode"));
            config.put("before", ftpConfig.getProperty("before"));
            config.put("result_path", ftpConfig.getProperty("result_path"));
            config.put("upload_path", ftpConfig.getProperty("upload_path"));
            config.put("hk_upload_path", ftpConfig.getProperty("hk_upload_path"));
            config.put("hkzs_upload_path", ftpConfig.getProperty("hkzs_upload_path"));
            config.put("file_name_prefix", ftpConfig.getProperty("file_name_prefix"));
            config.put("hkfile_name_prefix", ftpConfig.getProperty("hkfile_name_prefix"));
            config.put("hkzsfile_name_prefix", ftpConfig.getProperty("hkzsfile_name_prefix"));
            config.put("bak_upload_path", ftpConfig.getProperty("bak_upload_path"));
            //关闭流对象
            in.close();
        } catch (Exception ex) {
            logger.info("读取配置文件信息出错====", ex);
        }
    }

}
